package com.addplus.townmall.server.api.mapper.town;

import com.addplus.townmall.server.api.model.town.ChargeDetailMember;
import com.addplus.townmall.server.api.model.town.expand.ChargeDetailMemberExpand;
import com.addplus.townmall.server.api.utils.BaseAddMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

/**
 * <p>
 * 商城用户充值表 Mapper 接口
 * </p>
 *
 * @author zhangjiehang
 * @since 2018-08-27
 */
public interface ChargeDetailMemberMapper extends BaseAddMapper<ChargeDetailMember> {
    @Select("SELECT c.id,c.member_id,c.charge_time,c.charge_amount,c.charge_way,c.charge_status,c.present_amount,c.gmt_modified,m.nick_name,m.account FROM member m,charge_detail_member c WHERE m.id=c.member_id AND c.is_delete=0 AND m.is_deleted=0 ORDER BY c.gmt_modified DESC")
    List<ChargeDetailMemberExpand> getAllChargeDetailMember(IPage page);

    @Select("SELECT c.id,c.member_id,c.charge_time,c.charge_amount,c.charge_way,c.charge_status,c.present_amount,c.gmt_modified,m.nick_name,m.account FROM member m,charge_detail_member c WHERE m.id=c.member_id AND c.is_delete=0 AND m.is_deleted=0 AND c.charge_time BETWEEN #{start} AND #{end} ORDER BY c.gmt_modified DESC")
    List<ChargeDetailMemberExpand> getAllChargeDetailMemberByTime(IPage page,@Param("start") Date start, @Param("end") Date end);

    @Select("SELECT c.id,c.member_id,c.charge_time,c.charge_amount,c.charge_way,c.charge_status,c.present_amount,c.gmt_modified,m.nick_name,m.account FROM member m,charge_detail_member c WHERE m.id=c.member_id AND c.is_delete=0 AND m.nick_name like concat('%',#{nick_name},'%') ORDER BY c.gmt_modified DESC")
    List<ChargeDetailMemberExpand> getChargeDetailByNickName(IPage page,@Param("nick_name") String nick_name);

}
